package com.weiwei.WHadoop.io;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.io.compress.CompressionOutputStream;
import org.apache.hadoop.io.compress.GzipCodec;
import org.apache.hadoop.util.ReflectionUtils;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author WangWeiwei
 * @version 1.0
 * @sine 17-2-25
 * 从标准输入流获取数据源，压缩后输出到标准输出流
 */
public class StreamCompressor {
    public static void main(String[] args) throws ClassNotFoundException, IOException {
//        String codecClassName = args[0];
//        Class<?> codeClass = Class.forName(codecClassName);
        Configuration configuration = new Configuration();
        CompressionCodec compressionCodec = new GzipCodec();
        RandomAccessFile randomAccessFile = new RandomAccessFile("a.txt","rw");
        ByteBuffer byteBuffer = ByteBuffer.allocate(48);
        FileChannel fileChannel = randomAccessFile.getChannel();


        CompressionOutputStream compressionOutputStream = compressionCodec.createOutputStream(System.out);
        IOUtils.copyBytes(System.in,System.out,4096,false);
        compressionOutputStream.finish();
    }
}
